<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>コントロールパネル</title>
    <link href="./assets/styles/default.css" rel="stylesheet" />
    <script src="./assets/scripts/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="./assets/scripts/import.js" type="text/javascript"></script> 
    {include file='news/include/script.inc.html'}
</head>
<body>

{include file='include/header.inc.html'}

<div id="container">
	<aside id="accordion">
    	<div id="aside_inner">
    		{include file='include/menu.inc.html'}
        </div>
    </aside>
    
    <article>
    	<h2><span>&nbsp;</span>News<p><a href="javascript:;">Open Plugins</a></p></h2>
        <nav>
            <ul>
            	<li><a href="{$smarty.server.SCRIPT_NAME}"><span>検索</span></a></li>
            	<li class="active"><a href="{$smarty.server.SCRIPT_NAME}?op=regist"><span>登録</span></a></li>
            	<li><a href="{$smarty.server.SCRIPT_NAME}?op=setting"><span/>基本設定</a></li>
            </ul>
        </nav>
        
        <section id="content">
        
            {if isset($id)}{assign var=operation value='更新'}{else}{assign var=operation value='登録'}{/if} 
            <h3>{$operation}</h3>
            
		{if $phase == 'input'}
		
			<p class="message">内容を確認し、{$operation}ボタンをクリックしてください。</p>
			<form name="fm" action="{$smarty.server.SCRIPT_NAME}" method="post" enctype="multipart/form-data">
			<ul class="t_btns">
			{if $operation == '更新'}
				<li class="left delete"><button type="button" class="chk_delete"><em>&nbsp;</em>削除</button></li>
				<li class="center copy"><button type="button" class="chk_copy"><em>&nbsp;</em>コピーして新規登録</button></li>
				<li class="right refresh"><button type="button" class="chk_update"><em>&nbsp;</em>更新</button></li>
			{else}
				<li class="single add"><button type="button" class="chk_add"><em>&nbsp;</em>登録</button></li>
			{/if}
			</ul>

			<h4><span>&nbsp;</span>基本情報</h4>
			{include file='news/include/form.inc.html'}

			<p class="button">
			{if $operation == '更新'}
				<button type="button" id="btn_delete"><span>削除</span></button>
				<button type="button" id="btn_copy"><span>コピーして新規登録</span></button>
				<button type="button" id="btn_update" class="submit"><span>更新</span></button>
			{else}
				<button type="button" id="btn_regist" class="submit"><span>登録</span></button>
			{/if}
			</p>

			<input type="hidden" name="id" value="{$id}" />
			<input type="hidden" name="mode" value="" />
			<input type="hidden" name="do" value="{if $operation == '更新'}validate_edit_form{else}validate_regist_form{/if}"/>
	        </form>

		{elseif $phase == 'complete'}
		
	        <p class="message">{$message}</p>

{*	// 詳細不明な為、コメントアウト

		{if $id != ''}
        <div id="fb" style="float:left;margin-right:20px;padding-right:20px;border-right:1px solid #ddd;background:url(./assets/images/common/loading-white.gif) center center no-repeat;">
                <script type="text/javascript">
                        var url = encodeURI("{$news->getSiteUrl()}news/detail.php");
                        var id = encodeURI("{$forms.id}");
                        var title = "{$forms.title}";
                        var sub_title = "{$forms.sub_title}";
                        var thumb = ("{$forms.temp_name[0]}" != "") ? encodeURI("{$forms.temp_name[0]}") : "";

                        params = "url=" + url;
                        params += "&id=" + id;
                        params += "&title=" + title;
                        params += "&thumb=" + thumb;
                        params += "&description=" + sub_title;

                        document.write('<iframe id="sns_post" src="https://secure.shift-jp.net/fb_post/post.php?' + params + '" style="width:360px;height:300px;" frameborder="0"></iframe>');
                        $('#sns_post').load(function(){
                            $('#fb').css({ "background-position":"-10000px" })
                        })
                </script>
        </div>
        <div id="twitter" style="float:left;">
                <h1>Twitterへ投稿</h1>
                <a href="https://twitter.com/share" class="twitter-share-button" data-url="{$news->getSiteUrl()}news/detail.php?id={$forms.id}" data-text="{$forms.title}" data-lang="ja" data-size="large" data-count="none">ツイート</a>
                <script>
                        !function(d,s,id){
                            var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){ js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs); }
                        }(document,"script","twitter-wjs");
                </script>
        </div>
		{/if}
*}
					
        	<ul class="result_btn clear" style="margin-top:20px;">
                <li><a href="{$smarty.server.SCRIPT_NAME}">一覧に戻る</a></li>
                <li><a href="{$smarty.server.SCRIPT_NAME}?op=regist">続けて新規登録する</a></li>
            {if isset($id)}
                <li><a href="{$smarty.server.SCRIPT_NAME}?op=edit&id={$id}">登録した内容を更新する</a></li>
            {/if}
        	</ul>

		{/if}

        </section>
    </article>
    
</div>

{include file='include/footer.inc.html'}

</body>
</html>